
# # 有一个集合
# s = {'唐僧', '悟空', '八戒', '沙僧', '白龙马'}
# for x in s:
#     print(x)
# else:
#     print('遍历结束')
#
# # 请将上述代码改写成用while语句可迭代器实现


# 有一个集合
s = {'唐僧', '悟空', '八戒', '沙僧', '白龙马'}
for x in s:
    print(x)
else:
    print('遍历结束')

# 请将上述代码改写成用while语句可迭代器实现
its = iter(s)
while True:
    try:
        x = next(its)
        print(x)
    except StopIteration:
        print('遍历结束')

